package com.hkx.smipleemps.servlet;

import com.hkx.smipleemps.service.EmployeeService;
import com.hkx.smipleemps.service.EmployeeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/delemp.do")
public class DelEmpServlet extends HttpServlet {
    EmployeeService employeeService = new EmployeeServiceImpl();

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String idStr = request.getParameter("id");
        String pageNo = request.getParameter("pageNo");
        String pageSize = request.getParameter("pageSize");
        int id = Integer.parseInt(idStr.trim());
        employeeService.removeEmployee(id);
        //删除结束后 重定向到查询
        response.sendRedirect(request.getContextPath() + "/listEmployee.do?pageNo="+pageNo+"&pageSize="+pageSize);
    }
}
